package collection;

import java.util.Deque;
import java.util.LinkedList;

/**
 * @author DBX
 * @effect 双端队列
 *          java.util.Deque接口，其继承自Queue
 *          双端队列是队列的两端都可以做出入队的队列，实现类：LinkedList
 * @date 2021/09/04/14:08
 */
public class DequeDemo {
    public static void main(String[] args) {
        Deque<String> deque = new LinkedList<>();
        deque.offer("one");
        deque.offer("two");
        deque.offer("three");
        deque.offer("four");
        deque.offer("five");
        System.out.println(deque);
        deque.offerFirst("begin");//队首添加
        deque.offerLast("end");//队尾添加
        System.out.println(deque);

        deque.pollFirst();//删除队首
        deque.pollLast();//删除队尾
        System.out.println(deque);
        System.out.println(deque.peekFirst());
        System.out.println(deque.peekLast());
        System.out.println(deque);

    }}
